<?php

namespace App\Http\Controllers\Applet\Other;

use App\Services\Applet\Other\AreaService;
use Exception;
use Illuminate\Http\JsonResponse;

class AreaController extends BaseOtherController
{
    protected AreaService $areaService;

    /**
     * @throws Exception
     */
    public function __construct()
    {
        parent::__construct();
        $this->areaService = $this->loadService('Applet\Other\AreaService');
    }

    /**
     * 省市区地址列表
     * @return JsonResponse
     * @throws Exception
     */
    public function list(): JsonResponse
    {
        $rule = [
            'id' => 'integer|min:0',
        ];

        if ($this->ruleCheck($rule)) {
            return outputJsonError();
        }

        $list = $this->areaService->list($this->params);
        return outputJsonResult($list);
    }

}
